//
//  CZCategoryModelViewModel.m
//  i0S007通用项目
//
//  Created by Apple on 16/2/20.
//  Copyright © 2016年 Apple. All rights reserved.
//

#import "CZCategoryModelViewModel.h"
#import "CZCategoryModel.h"

@implementation CZCategoryModelViewModel

- (NSArray *)categories {
    if (_categories == nil) {
        // 获取路径
        NSString *path = [[NSBundle mainBundle] pathForResource:@"categories.plist" ofType:nil];
        
        // 将plist的数据加载到内存中
        NSArray *array = [NSArray arrayWithContentsOfFile:path];

        NSMutableArray *categoriesM = [NSMutableArray array];
        
        // 字典转模型
        for (NSDictionary *dict in array) {
            CZCategoryModel *categoryModel = [[CZCategoryModel alloc] initWithDict:dict];
            [categoriesM addObject:categoryModel];
        }
        
        // 赋值
        _categories = categoriesM;
    }
    
    return _categories;
}
@end
